home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
graphic
/
vesa_tsr.zip
/
C&T
/
VESA452.ASM
< prev
next >
Wrap
Assembly Source File
|
1990-04-18
|
24KB
|
908 lines
page 70, 132
;----------------------------------------------------------------------
; Module Name :VESA452.asm
; Program Name :VESA452.com
; Description :This program traps Video BIOS Fuction calls made from an
; Application program. It is a TSR(Terminate & Stay Resident)
; program.
; Date :February 26, 1990
; Version :1.0
; Programmer :Rakesh K. Jain
; Copyright (C) Chips and Technologies, Inc. 1990
;----------------------------------------------------------------------
include vesa.inc ; to include VESA structures & constants
include vesa452.inc ; 452 related stuff
;
; Code Segment Starts
;
code segment
assume cs:code, ds:code, ss:code, es:code
org 100h ;for making the program .COM type
begin :
jmp main ; jump to the initialization part
;------------------------------------------------------------------
; This routine stores BIOS Video Function Number into a Buffer
; and then calls BIOS fuction.
;------------------------------------------------------------------
VideoHandler proc near
; look for functions to be implemented here
cmp ah, VESA_FUNCTIONS
jnz VHNotVGACntlFun
; Its a VESA function
call VESAFunctions
iret
VHNotVGACntlFun:
pushf ;Push Flags to compensate for IRET
callfar
oldvect dw 0
dw 0 ;Old Video Interrupt Vector
iret
VideoHandler endp
VESAFunctions proc near
cmp al, MAX_FUNCTIONS
ja VESAFNotAValidFunction
cmp al,5 ; Window Control function
jnz @F
push cs
call near ptr SuperVGASetCPUMemWin ; This is far call
ret
@@:
pushem <es,ds,di,si,dx,cx,ax,bx> ; dont change ax, bx order
xor ah, ah
shl ax, 1 ; ax = function index
xchg ax, bx
mov bx, cs:DispatchTable[bx] ; function ptr in bx
xchg ax, bx
call ax
DirectReturn:
popem <bx,ax,cx,dx,si,di,ds,es> ; dont change ax, bx order
mov ax, cs:Status
ret
VESAFNotAValidFunction:
cmp al, 70h
jne @f
call SetChipsWindowSize
mov ax, 704fh
ret
@@:
cmp al, 71h
jne @f
call GetChipsWindowSize
mov ax, 714fh
ret
@@:
xor al, al ; function not supported
ret
VESAFunctions endp
SuperVGAInfo proc near
;
; copy our info structure
;
cld ; play it safe, don't assume things
mov ax, cs
mov ds, ax ; Set our data segment
mov si, OFFSET VGAInfo
mov cx, (SIZE VGAInfoBlock) / 2
rep movsw
IF (SIZE VGAInfoBlock) AND 1
movsb
ENDIF
if 0 ;** we assume that 82C452 presence is already been checked, when we installed this TSR
;
; Look for 82C452 (CHIPS Super VGA)
;
call ReadChipsVGAId ; Id is returned in ah
;
; if VGA is identified as Chips product then look for specific VGA
; look for Chips Id
;
cmp ah, CHIPS_ID ; is it chips Id?
jnz VGACError00 ; non Chips VGA/EGA
;
; VGA is identified as Chips VGA
;
mov ah, 80H ; open extended registers at 3d6/3d7H
call ExtRegs
call ReadVGATypeNRev
mov bl, ah ; place this info to proper reg
and ah, 0F0H ; test VGA type
cmp ah, CHIPSVGA_452
jnz VGACFNot452
;
; 82C452 is found, return success
;
endif ;**0
mov Status, SUCCESS SHL 8 + VESA_FUNCTIONS
ret
if 0 ;** Presence of 82c452 is alraedy been checked
VGACError00:
VGACFNot452:
mov Status, FAILURE SHL 8 + VESA_FUNCTIONS
ret
endif ;** 0
SuperVGAInfo endp
SuperVGAModeInfo proc near
cld ; play it safe
mov ax, cs
mov ds, ax ; Set our data segment
mov si, OFFSET ModeInfo
mov ax, cx ; VESA Mode No ****** to be changed to bx
mov dx, di ; save di in dx
mov bx, es ; save es in bx
call VESAToInternalMode
call InternalModeToIndex
mov ax, di ; al = Mode Index
mov ah, SIZE ModeInfoBlock
mul ah ; ax = +(SIZE ModeInfoBlock)*Index
add si, ax ; si = ModeInfo+(SIZE ModeInfoBlock)*Index
mov di, dx ; restore di
mov es, bx ; restore es
mov cx, OBLG_INFO_SIZE
test [si].ModeAttributes, MA_EXT_INFO
jz @F
add cx, EXT_INFO_SIZE
@@:
push di ; save start address
rep movsb
pop di ; restore start adress
mov ax, word ptr ChipsNoOfWindows
; al = # of Windows, ah = Window Size
cmp al, 1 ; Is there only 1 windows supported
jz @F ; By default we enable only one window
mov es:[di].WinBAttributes,WIN_ATTR ; Enable second window also
cmp ah, 64 ; Is it Dual page 64K ?
jz @F ; Yes, we are all set
mov es:[di].WinBSegment, WINB_NADDR ; change selector to dual page 32K windows
@@:
mov byte ptr es:[di].WinSize, ah ; copy size of the window
mov cs:Status, SUCCESS SHL 8 + VESA_FUNCTIONS
ret
SuperVGAModeInfo endp
SuperVGASetMode proc near
mov ax, bx ; ax = VESA Mode
call VESAToInternalMode ; ax = Internal Mode (BIOS Mode)
mov bx, ax ; save internal mode
and ah, ah ; see if ah = 0
jnz SVSMError
int 10H ; call BIOS to set mode
; did BIOS set the mode ?
mov ax, 40h
mov ds, ax
mov di, 49h
and bl, NOT 80H ; Clear Not-clear-memory bit
cmp [di], bl
jnz SVSMError
;
; find out what value is to be programmed in the GR06 and XR0B to select
; proper CPU address window. We have table of these value so we have
; to compute index to the table first. There are 4 entries in the table.
; NumberOfWin SizeofWin XR0B GR06 (Low)
; 1 64 K 0 4
; 1 128K 0 0
; 2 32 K 2 4
; 2 64 K 2 0
; We assume that # of windows and windows size will always have these values
;
cmp bl, 6ah ; For all standard modes and 132 column modes
jb StandardModes ; don't bother about paging etc
mov bx, word ptr cs:ChipsNoOfWindows
; bl = # of Windows, bh = Window Size
mov cl, 6 ; # of bits to be shifted
shr bl, 1 ; 'C' if bl = 1, bl = 0/1
adc cl, 0 ; cl = 6/5
shr bh, cl ; bl = 0/1
shl bl, 1
add bl, bh
xor bh, bh ; bx = index into the table
shl bx, 1 ; each entry is one word
mov dx, 3ceh ; dx = Graphics Controller addr
mov al, 6
out dx, al
inc dx
in al, dx
and al, 11110011b ; clear memory size bits
or al, cs:WinRegTable[bx] ; GR06 value
out dx, al
mov ah, 80h ; Open extended registers
call ExtRegs
mov dx, EGA_BASE + EXTR_ADDR
mov al, 0bh
out dx, al
inc dx
in al, dx ; read current value
and al, 11111101b ; clear dual page bit
or al, cs:WinRegTable[bx+1] ; XR0B value
out dx, al
StandardModes:
mov cs:Status, SUCCESS SHL 8 + VESA_FUNCTIONS
ret
SVSMError:
mov cs:Status, FAILURE SHL 8 + VESA_FUNCTIONS
ret
SuperVGASetMode endp
SuperVGAGetMode proc near
mov ax, 0F00H
int 10H
xor ah, ah
mov bx, ax ; save this info in bx
call InternalModeToVesa
jnc @F
xchg ax, bx
@@:
pop dx ; get return addr
pop ax ; pop bx in ax *******
push bx ; push mode to be returned
push dx ;
mov cs:Status, SUCCESS SHL 8 + VESA_FUNCTIONS
ret
SuperVGAGetMode endp
SuperVGAVideoState proc near
mov ah, 1cH ; ah = BIOS function to save/restore VIDEO state
mov al, dl ; al = subfunction
push ax ; save function
push cx
test cx, VS_SUPERVGA_STATE
jz SVVSNotSuperVGA0
;
; Super VGA state
;
cmp al, VS_GET_BUFSIZE
jnz SVVSNotBufSize
;
; get buf size function
;
cmp cx, VS_SUPERVGA_STATE ; if it is SUPERVGA_STATE only
jnz @F ; save cx, ax and call BIOS
; only SUPERVGA_STATE
mov bx, SUPERVGA_SIZE
pop cx
pop ax ; restore sunfunction
jmp SVVSNotSuperVGA1 ; don't call BIOS
SVVSNotBufSize:
cmp al, VS_SAVE_STATE
jnz SVVSNotSaveState
;
; save state function
; es:bx --> pointer to buffer, bx will be updated by routine
;
call SaveSuperVGAState
jmp short @F
SVVSNotSaveState:
cmp al, VS_RESTORE_STATE
jnz SVVSNotRestoreState
;
; restore state function
; es:bx --> pointer to buffer, bx will be updated by routine
;
call RestoreSuperVGAState
SVVSNotRestoreState:
SVVSNotSuperVGA0:
@@:
int 10H
pop cx ; restore requested state
pop ax ; restore subfunction function
test cx, VS_SUPERVGA_STATE
jz SVVSNotSuperVGA1
; super vga function
cmp al, VS_GET_BUFSIZE ; is it GET_BUFSIZE function ?
jnz @F ; no
add bx, SUPERVGA_SIZE ; add # of full block
SVVSNotSuperVGA1:
pop dx ; pop return address
pop ax ; pop bx in ax *******
push bx ; put bx on stack
push dx ; push new address
@@:
mov cs:Status, SUCCESS SHL 8